package com.t18;

import java.io.*;
import java.util.Date;

import static net.mindview.util.Print.print;

/**
 * Created by xuyiwei on 2018/9/5.
 */
public class Logon implements Serializable {
    private Date date = new Date();
    private String username;
    private transient String password;
    public Logon(String username, String password) {
        this.username = username;
        this.password = password;
    }
    public String toString(){
        return "logon info \n username: "+username+" \n date: "+date+"\n password:"+password;
    }
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        Logon a = new Logon("Hulk","myLittelPony");
        print("logon a = "+a);
        ObjectOutputStream out = new ObjectOutputStream(
                new FileOutputStream("Logon.out")
        );
        out.writeObject(a);
        ObjectInputStream in = new ObjectInputStream(
                new FileInputStream("Logon.out")
        );
        System.out.println(in.readObject());
        /**
         * logon a = logon info
         username: Hulk
         date: Wed Sep 05 18:07:32 CST 2018
         password:myLittelPony

         logon info
         username: Hulk
         date: Wed Sep 05 18:07:32 CST 2018
         password:null
         */
    }
}
